/* ***********************
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is SiteName.js module.
 *
 * The Initial Developer of the Original Code is Rob Gerns.
 *
 * Portions created by the Initial Developer are Copyright (C) 2010
 * the Initial Developer. All Rights Reserved.
 *
 **************************/
 
 
/*************************************************
* Function Name(s): SiteName_Link; writeSitename
*
* Purpose:
* Check to see if site name and site link are defined,
* if so then create a div to contain the site name
* and make that into a link to the site using the 
* value found in the 'sitelink' element.
***************************************************/  

function siteName_Link(oisterFile){ 
 
 /* The sitelink info (this is required for an Oister file so it shouldn't 
  * be blank or undefined...although it might be */
 var checksl = oisterFile.getElementsByTagName("sitelink").length; 
 
 //The name of the site (also required in an Oister file)
 var checksn = oisterFile.getElementsByTagName("sitename").length; 
 
 //Make sure sitelink value exists, otherwise make it blank
 if(checksl > 0  && checksl !=undefined) {
  sitelink = oisterFile.getElementsByTagName("sitelink").item(0).firstChild.data;
 }
 else sitelink = "";
	  
 //Make sure sitename value exists, otherwise make it blank
 if(checksn > 0 && checksn !=undefined) {
  sitename = oisterFile.getElementsByTagName("sitename").item(0).firstChild.data;
 }
 else sitename = "";
	
 //Call the writeSitename function to create the appropriate div
 writeSitename(sitename,sitelink);

}


function writeSitename(sname,slink){

 //Create the div that contains the site name and link, make the site name into a link
 divSitename = document.createElement("div");
 sitenameId = divSitename.id = "sitename";
 divSitename.className = "sitename";
 document.getElementById('begin').appendChild(divSitename);
 document.getElementById(sitenameId).innerHTML = '<a href="' + slink + '" class="sitetitle">' + sname + '</a>';
	
}